#pragma once
#include "IEffect.h"
#include "WarePrepare.h"

BEGIN_WARE

class IEffectProp;
class IEffectUnitProp;
class IEffectUnit;
class CEffectUnit;
class ISceneNodeCamera;
class IResourceManager;

struct SEffectTrack
{
	SEffectTrack() : pEffectUnit(NULL), fStartPos(0.0f), fEndPos(1.0f), bActive(VFALSE) {}

	IEffectUnit*	pEffectUnit;
	float32			fStartPos;
	float32			fEndPos;
	VBOOL			bActive;
};

class CEffect : public IEffect
{
public:
	CEffect( uint32 uID );
	~CEffect(void);

	typedef vector< SEffectTrack* > EffectUnitVec;

	/// ISceneEntity
	virtual int32					GetEntityType()		{ return ENTITYNODE_EFFECT; };

	virtual ISceneNodeTransform*	GetParent()			{ return m_pParent; }

	virtual void					CullVisibleObjects( IGraphic* pGraphic, ISceneNodeCamera* pCamera );

	virtual void					SetParent( ISceneNodeTransform* pNode )	{ m_pParent = pNode; }

	virtual void					SetWireFrameMode( VBOOL bWireFrame )	{ m_bWireFrameMode = bWireFrame; }

	virtual void					SetVisible( VBOOL bVisible )	{ m_bVisible = bVisible; }
	virtual VBOOL					IsVisible()						{ return m_bVisible; }

	virtual int32					Grab() { return 0; }
	virtual int32					Drop();

	virtual uint32					GetID()							{ return m_uID; }


	virtual VBOOL					Update( IGraphic* pGraphic, uint32 uCurTime );
	virtual VBOOL					Render( IGraphic* pGraphic, uint32 uCurTime );

	virtual IEffectProp*			GetEffectProp();

	VBOOL							CreateEffect( IResourceManager* pResMgr, IEffectProp* pEffectProp );
	CEffectUnit*					CreateEffectUnit( IEffectUnitProp* pEffectUnitProp );
	void							ReleaseEffectUnit( IEffectUnit* pEffectUnit );



private:

	uint32							m_uID;
	ISceneNodeTransform*			m_pParent;	

	IEffectProp*					m_pEffectProp;

	EffectUnitVec					m_vecEffectUnitTrack;


	uint32							m_uStartTime;
	VBOOL							m_bVisible;
	VBOOL							m_bWireFrameMode;
};

END_WARE
